import {Component} from "react";
import WebView from "react-native-webview";
import {apiDomain} from "../../common/api";
import {StyleSheet, View} from "react-native";

export default class Web extends Component {
    componentDidMount() {
        const {navigation, route} = this.props
        console.log(this.getUrl())
    }

    getUrl() {
        const {route} = this.props
        if (apiDomain.includes("?")) {
            return apiDomain + '/Index/uploadPayment&id=' + route.params.id + '&type=' + route.params.type
        } else {
            return apiDomain + '/Index/uploadPayment?id=' + route.params.id + '&type=' + route.params.type
        }
    }

    render() {
        const {navigation, route} = this.props
        return (
            <View style={styles.container}>
                <WebView
                    ref="webview"
                    style={{flex: 1}}
                    source={{uri: this.getUrl()}}
                />
            </View>
        );
    }
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
    },
});
